package com.heima.datastructure.binarytree;

/**
 * @author 勾新杰
 * @version 1.0
 * @date 2024/9/7 18:19
 */
public class TreeNode<E> {
    public E value; // 值
    public TreeNode<E> left; // 左孩子，默认null
    public TreeNode<E> right; // 右孩子，默认null

    public TreeNode(E value) {
        this.value = value;
    }

    public TreeNode(E value, TreeNode<E> left, TreeNode<E> right) {
        this.value = value;
        this.left = left;
        this.right = right;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        TreeTraversal.levelOrder(this,e->builder.append(e.toString()).append(" "));
        return builder.toString();
    }
}
